package com.kalix.mooc.reply.biz;

import com.kalix.framework.core.api.persistence.JsonData;
import com.kalix.framework.core.impl.biz.ShiroGenericBizServiceImpl;
import com.kalix.mooc.reply.api.biz.IQuickCommentBeanService;
import com.kalix.mooc.reply.api.dao.IQuickCommentBeanDao;
import com.kalix.mooc.reply.api.dto.NoteDTO;
import com.kalix.mooc.reply.api.dto.QuickCommentDTO;
import com.kalix.mooc.reply.entities.QuickCommentBean;

import java.util.List;

/**
 * 功能描述:
 *
 * @Description: 快速评论实现
 * @Author: yyp
 * @CreateDate: 2019/5/28$ 10:14$
 * @Version:
 */
public class QuickCommentBeanServiceImpl extends ShiroGenericBizServiceImpl<IQuickCommentBeanDao, QuickCommentBean> implements IQuickCommentBeanService {
    @Override
    public JsonData getAllQuickComment(String cid) {
        String sql = "select q.id,q.name,q.cid,q.cname from mooc_quickcomment q, mooc_course c where c.id = q.cid";
        if (!cid.isEmpty() && cid!=null) {
            sql += " and q.cid=" + cid;
        }
        List<QuickCommentDTO> list = dao.findByNativeSql(sql, QuickCommentDTO.class);
        JsonData jsonData = new JsonData();
        jsonData.setData(list);
        jsonData.setTotalCount((long) list.size());
        return jsonData;
    }
}
